﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFNote.Utilities.CacheHelper
{
    /// <summary>
    /// 缓存服务
    /// </summary>
    public interface ICacheService
    {
        /// <summary>
        /// 写入缓存
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        bool Save<T>(string key, T value);
        /// <summary>
        /// 写入缓存
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="expire">多少秒后过期</param>
        /// <param name="isSlidingExpiration">是否滑动过期</param>
        bool Save<T>(string key, T value, int expire, bool isSlidingExpiration = false);
        /// <summary>
        /// 删除缓存
        /// </summary>
        /// <param name="key">键</param>
        void Remove(string key);
        /// <summary>
        /// 清空缓存
        /// </summary>
        void RemoveAll();
        /// <summary>
        /// 获取缓存值
        /// </summary>
        /// <typeparam name="T">值类型，class</typeparam>
        /// <param name="key">键</param>
        /// <returns></returns>
        T Get<T>(string key) where T : class;
    }
}
